//
//  YeeEditSelfVC.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/9.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeEditSelfVC.h"
#import "XRCommonLeftLableWithRImageTableCell.h"
#import "XRSelfEditNickNameViewController.h"
@interface YeeEditSelfVC ()
{
    
}
@end

@implementation YeeEditSelfVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)addOwnViews
{
    [super addOwnViews];
}
-(void)addNavbarView
{
    [super addNavbarView];
    self.title=@"个人信息";
}
-(void)configOwnViews
{
    [super configOwnViews];
}
-(void)bindViewModel
{
    [super bindViewModel];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row==0)
    {
        XRCommonLeftLableWithRImageTableCell *headerCell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XRCommonLeftLableWithRImageTableCell class])];
        if (!headerCell) {
            headerCell=[[XRCommonLeftLableWithRImageTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XRCommonLeftLableWithRImageTableCell class])];
        }
        headerCell.textLabel.text=@"头像";
        headerCell.textLabel.font=[UIFont systemFontOfSize:14];
        headerCell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        headerCell.selectionStyle=UITableViewCellSelectionStyleNone;
        return headerCell;
        
    }else
    {
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
        if (cell==nil)
        {
            cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([ UITableViewCell class])];
        }
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.font=[UIFont systemFontOfSize:14];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.detailTextLabel.textAlignment=NSTextAlignmentRight;
        NSArray *titleArray=@[@"用户名",@"性别",@"生日"];
        cell.textLabel.text=titleArray[indexPath.row-1];
        return cell;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 46;
}
#pragma mark --点击单元格
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            [self callImagePickerActionSheet];
            break;
        case 1:
        {
            XRSelfEditNickNameViewController  *editVC=[XRSelfEditNickNameViewController new];
            editVC.title=@"用户名";
            editVC.editType=XREditControllerNickType;
            editVC.placeHolder=@"请输入你的昵称(3-20字)";
            editVC.endBlock=^(NSString *textString)
            {
            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
            };
            [self.navigationController pushViewController:editVC animated:YES];
        }
            break;
        case 2:{
            [self  viewControllerPOPPickerType:YWCategoryPickerSexType withsuccessBlock:^(NSString *string) {
            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:2 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
            }];
        }
            break;
        case 3:{
            
            [self  viewControllerPOPPickerType:YWCategoryPickerAgeType withsuccessBlock:^(NSString *string)
            {
            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:3 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
            }];
        }
            break;
        default:
            break;
    }
}
#pragma mark --获取头像
#pragma mark --获取
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    
//    UIImage *selectIma = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
//    _headerImage=selectIma;
//    [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
//    [picker dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
